#!/usr/bin/python
# -*- coding: UTF-8 -*-
import sys,os,shutil

curPath = sys.path[0]
pubPath = u"W:\\开发资源\\cpp\\jsoncpp-1.6.5\\bin"


'''
    ext:jpg,png
    src:源路径列表
        ["a","b"]
    dst:目标路径
        "d:\\soft"
'''
def copyFolder(ext,src,dst):
    extArr = ext.split(",")
    
    for p in src:
        fd_part = os.path.split(p)
        #fd_part[1] #目录名称        
        
        for dirpath,dirnames,filenames in os.walk(p):
            
            #遍历所有文件
            for f in filenames:
                f_path = os.path.join(dirpath,f)                
                
                f_path_part = os.path.splitext(f_path)
                #f_path_part[1] 文件扩展名称
                f_ext = f_path_part[1].replace(".","")
                                
                #是指定的扩展名称
                if f_ext in extArr:
                    f_dst = os.path.join(dst , fd_part[1])                    
                    f_dst = f_dst + f_path.replace(p,"")                    
                    dst_part = os.path.split(f_dst)
                    print f_dst
                    
                    #目录不存在
                    if os.path.exists(dst_part[0])!=True:                        
                        os.makedirs(dst_part[0])
                    shutil.copy(f_path,f_dst)
    return

#发布到nas
modules = [curPath + "\\bin\\x86"]
copyFolder("dll,lib",modules,pubPath)